# 这个函数承担着绘制结果图表的功能，以便展示“model”训练的效果
def display_results(history, training_result_dir):
    import matplotlib.pyplot as plt
    import os
    import numpy as np
    # from Global_variable_setting import experiment_time
    history_dirt = history.history
    metrics = history_dirt['mae']
    val_metrics = history_dirt['val_mae']
    loss = history_dirt['loss']
    val_loss = history_dirt['val_loss']

    plt.subplot(121)
    epochs = range(1, len(loss) + 1)
    plt.plot(epochs, loss, 'r+', label='Training loss')   # 开始绘制有关“loss”的图表
    plt.plot(epochs, val_loss, 'b', label='Validation loss')
    plt.title('Training and validation loss')
    plt.xlabel('epochs')
    plt.ylabel('loss')
    plt.legend()
    plt.tight_layout()

    plt.subplot(122)
    plt.plot(epochs, metrics, 'r+', label='Training mae')    # 开始绘制有关“accuracy”的图表
    plt.plot(epochs, val_metrics, 'b', label='Validation mae')
    plt.title('Training and validation mae')
    plt.xlabel('epochs')
    plt.ylabel('mae')
    plt.legend()
    plt.tight_layout()

    # i = str(experiment_time)
    # path_prefix = os.getcwd() + '/result/'
    if not os.path.exists(training_result_dir+'/plot'):
        os.mkdir(training_result_dir+'/plot')
    plt.savefig(training_result_dir+'/plot/figure')
    np.save(training_result_dir+'/plot/mae', metrics, allow_pickle=False, fix_imports=False)
    np.save(training_result_dir+'/plot/val_mae', val_metrics, allow_pickle=False, fix_imports=False)
    np.save(training_result_dir+'/plot/loss', loss, allow_pickle=False, fix_imports=False)
    np.save(training_result_dir+'/plot/val_loss', val_loss, allow_pickle=False, fix_imports=False)
    plt.show()
